package hk.m4s.lr.repair.test.ui.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.WorkBean;


/**
 * Created by admin on 2016/8/22.
 */
public class WorkAdapter extends BaseAdapter {
    private Context context;
    public List<WorkBean> list;
    private LayoutInflater flater;
    Bitmap bi = null;
    public int flags;

    public WorkAdapter(Context context, List<WorkBean> list) {
        this.context = context;
        this.list = list;
        this.flater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();

            convertView = flater.inflate(R.layout.select_item, null);
            holder.type_name = (TextView) convertView
                    .findViewById(R.id.item_user);


            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        if (list != null) {
            WorkBean been = list.get(position);
            holder.type_name.setText(been.getName());
            if(flags==position){
                holder.type_name.setTextColor(Color.parseColor("#000000"));
            }else{
                holder.type_name.setTextColor(Color.parseColor("#777777"));
            }

        }

        return convertView;
    }

    static class ViewHolder {
        public TextView type_name;
        public LinearLayout layout;
    }



}
